﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using TradeClient.Logic.TradeCore;

namespace TradeClient
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            init();
        }

        private void init()
        {
            QuoteManager quoteManager = QuoteManager.GetInstance();

            KLineSeries kSeries = new KLineSeries(MarketType.Futures, "ru1301", 1, KLineUnitType.Minutes);

            kSeries.PriceUpdate += kSeries_PriceChange;
            kSeries.KLineFinished += kSeries_KLineFinished;

            quoteManager.Add(kSeries);

            CoreManager coreManager = new CoreManager();
            coreManager.StartQuote();
        }

        void kSeries_PriceChange(KLineSeries series)
        {
            Action ac = () =>
            {
                label1.Text = series[0].Close.ToString();
            };

            this.Invoke(ac);
        }

        void kSeries_KLineFinished(KLineSeries series)
        {
            
        }

        
    }
}
